﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Srv3CodeTool
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void MenuAbout_Click(object sender, EventArgs e)
        {
            Form fm = new AboutBoxCodeTool();
            fm.ShowDialog();
        }

        private void MenuOptions_Click(object sender, EventArgs e)
        {
            Form fm = new FrmOption();
            fm.ShowDialog();
        }

        private void MenuExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void MenuNewModule_Click(object sender, EventArgs e)
        {
            Form fm = new FrmNewModule();
            fm.ShowDialog();
        }

        private void MenuAdapterInterface_Click(object sender, EventArgs e)
        {
            Form fm = new FrmAdapterInterface();
            fm.ShowDialog();
        }

        private void MenuNewLua_Click(object sender, EventArgs e)
        {
            Form fm = new FrmNewLua();
            fm.ShowDialog();
        }

        private void MenuProviderInterface_Click(object sender, EventArgs e)
        {
            Form fm = new FrmProviderInterface();
            fm.ShowDialog();
        }

        private void MenuConsumerInterface_Click(object sender, EventArgs e)
        {
            Form fm = new FrmConsumerInterface();
            fm.ShowDialog();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {

        }

        private void MenuModuleTemplate_Click(object sender, EventArgs e)
        {
            Functions func = new Functions();
            try
            {
                string strPath = func.GetTemplatePath() + "\\NewModule";
                if (!Directory.Exists(strPath))
                {
                    Functions.ShowMsgBox("在" + strPath + "找不到模块模板", MSGBOX_TYPE.MSGBOX_TYPE_NOTICE);
                }
                System.Diagnostics.Process.Start("explorer.exe", strPath);
            }
            catch (System.Exception ex)
            {
                Log.LogSave(ex.ToString(), LOGTYPE.LOGTYPE_ERROR);
            }
        }

        private void MenuLuaTemplate_Click(object sender, EventArgs e)
        {
            Functions func = new Functions();
            try
            {
                string strPath = func.GetTemplatePath() + "\\NewLua\\NewLua.sql";
                if (!File.Exists(strPath))
                {
                    Functions.ShowMsgBox("在" + strPath + "找不到模块模板", MSGBOX_TYPE.MSGBOX_TYPE_NOTICE);
                }
                System.Diagnostics.Process.Start("notepad.exe", strPath);
            }
            catch (System.Exception ex)
            {
                Log.LogSave(ex.ToString(), LOGTYPE.LOGTYPE_ERROR);
            }

        }

        private void MenuPtrCheck_Click(object sender, EventArgs e)
        {
            Form fm = new FrmPtrCheck();
            fm.ShowDialog();
        }
        
    }
}
